package com.wdb.exception.handler;

import lombok.Data;

/**
 * 统一响应错误
 *
 * @author: wendaobai@qq.com
 * @date: 2024/1/9 0009 17:18
 */
@Data
public class ApiError {
  private Integer status = 400;
  private Long timestamp;
  private String message;

  private ApiError() {
    timestamp = System.currentTimeMillis();
  }

  public static ApiError error(String message) {
    ApiError apiError = new ApiError();
    apiError.setMessage(message);
    return apiError;
  }

  public static ApiError error(Integer status, String message) {
    ApiError apiError = new ApiError();
    apiError.setStatus(status);
    apiError.setMessage(message);
    return apiError;
  }
}
